<?php
    $jml_kelompok  = count($data['kelompok']);
    $jml_peralatan = count($data['peralatan']);
    $jml_material  = count($data['material']);
?>
<script type="text/javascript">
$(document).ready(function(){
	// functions
	<?php require('library/js/validator/functions.js');?>
	
	// peralatan
    // init
    var jml_peralatan = <?=$jml_peralatan+1;?>;
	<?php require('library/js/form/input.peralatan.js');?>
	
	// material
    // init
    var jml_material = <?=$jml_material+1;?>;
	<?php require('library/js/form/input.material.js');?>
	
	// kelompok
    // init
    var jml_kelompok = <?=$jml_kelompok+1;?>;
	<?php require('library/js/form/input.kelompok.js');?>	
	
	
	// VALIDATOR
	// material
	<?php require('library/js/validator/form.input.material.js');?>
	
	// peralatan
	<?php require('library/js/validator/form.input.peralatan.js');?>	
	
	// peralatan
	<?php require('library/js/validator/form.input.kelompok.js');?>	
	
	// VALIDATOR
	<?php require('library/js/validator/config.pembibitan_mainnursery.js');?>	
	
	// date picker
	$('input#tgl_pembibitan').datePicker();
    
    // remove blank input
    // kelompok
    $('input#jml_kelompok-<?=$jml_kelompok;?>').focus();
});

</script>
<div class="title">Pembibitan Mainnursery</div>

<textarea style="display:none" id="template_peralatan">
	<li><span>
			<label>{0}</label>
			<input type="text" id="nama_peralatan-{0}" name="nama_peralatan-{0}" class="nama_peralatan"/>
			<input type="text" id="jml_peralatan-{0}" name="jml_peralatan-{0}" class="jumlah_peralatan"/>
			<input type="button" class="hapus_peralatan button"  name="hapus_peralatan" value="Hapus"/>
		</span>
	</li> 
</textarea>
<textarea style="display:none" id="template_material">
	<li><span>
		<label>{0}</label>
		<?=$combobox;?>
		<input type="text" id="jml_material-{0}" name="jml_material-{0}" value="" class="jumlah_material"/>
		<input type="text" id="satuan_material-{0}" name="satuan_material-{0}" value="" rel="Satuan" class="satuan_material"/>
		<input type="button" class="hapus_material button" name="hapus_material" value="Hapus"/>
	</span></li>
</textarea>
<textarea style="display:none" id="template_material_other">
	<li><span>
		<label>{0}</label>
		<input type="text" id="nama_material-{0}" name="nama_material-{0}" value="" class="nama_material"/>
		<input type="text" id="jml_material-{0}" name="jml_material-{0}" value="" rel="Jumlah" class="jumlah_material"/>
		<input type="text" id="satuan_material-{0}" name="satuan_material-{0}" value="" rel="Satuan" class="satuan_material"/>
		<input type="button" class="hapus_material" name="hapus_material" value="Hapus"/>
	</span></li>
</textarea>
<textarea style="display:none" id="template_kelompok">
	<li><span>
		<label>{0}</label>
		<input type="text" id="nama_kelompok-{0}" name="nama_kelompok-{0}" value="" class="nama_kelompok"/>
		<input type="text" id="jml_kelompok-{0}" name="jml_kelompok-{0}" value="" class="jumlah_kelompok"/>
		<input type="button" class="hapus_kelompok" name="hapus_kelompok" value="Hapus"/>
	</span></li>
</textarea>
<form name="frm_<?=$subbagian;?>" id="frm_<?=$subbagian;?>" method="post" action="index.php?bagian=<?=$bagian;?>&subbagian=<?=$subbagian;?>&action=confirm_edit">
    <ul>
    	<li class="header"><span>Perlakuan</span></li>
        <li><span>
            <label>Tanggal Pembibitan:</label>
            <input type="text" id="tgl_pembibitan" name="tgl_pembibitan" value="<?=$data['tgl_pembibitan'];?>" readonly="readonly" class="disabled"/>
        </span></li>
        <li class="header"><span>Kelompok</span></li>
        <li class="desc">
			<span class="col1">Nama Kelompok</span>
			<span class="col5">Jumlah Bibit</span>
		</li>
        <?php
        $no  = 0;
        $sum = 0;
        foreach($data['kelompok'] as $kelompok){
        ?>
        <li><span>
            <label><?=++$no;?></label>
            <input type="text" id="nama_kelompok-<?=$no;?>" name="nama_kelompok-<?=$no;?>" value="<?=$kelompok['nama'];?>" class="nama_kelompok"/>
            <input type="text" id="jml_kelompok-<?=$no;?>"  name="jml_kelompok-<?=$no;?>"  value="<?=$kelompok['jumlah'];?>" class="jumlah_kelompok"/>
            <input type="button" class="hapus_kelompok" name="hapus_kelompok" value="Hapus"/>
        </span></li>
        <?php
            $sum+=$kelompok['jumlah'];
        }
        ?>
 		<li class="button">
	      <input type="button" name="tambah_kelompok" id="tambah_kelompok" value="Tambah Baris"/>
	    </li>
        <li><span><label class="total_bibit">Total Bibit:</label>
            <input type="text" id="total_bibit" name="total_bibit" value="<?=$sum;?>" readonly="readonly" class="total_bibit"/>
        </span></li>
    </ul>
    <ul>
		<li class="header"><span>Pekerja</span></li>
		<li><span>
            <label>Penanggung Jawab:</label>
            <input type="text" id="penanggung_jawab" name="penanggung_jawab" value="<?=$data['penanggung_jawab'];?>"/>
        </span></li>
		<li><span>
            <label>Jumlah Pekerja:</label>
            <input type="text" id="jml_pekerja" name="jml_pekerja" value="<?=$data['jml_pekerja'];?>"/>
        </span></li>
		<li><span>
            <label>Total Biaya Pekerja:</label>
            <input type="text" id="biaya_pekerja" name="biaya_pekerja" value="<?=$data['biaya_pekerja'];?>"/>
        </span></li>
    </ul>
    <ul id="peralatan">
		<li class="header"><span>Peralatan</span></li>
		<li class="desc">
			<span class="col1">Nama Peralatan</span>
			<span class="col2">Jumlah</span>
		</li>
	    <?php
        $no  = 0;
        $sum = 0;
        foreach($data['peralatan'] as $peralatan){
        ?>
        <li><span>
            <label><?=++$no;?></label>
            <input type="text" id="nama_peralatan-<?=$no;?>" name="nama_peralatan-<?=$no;?>" value="<?=$peralatan['nama'];?>" class="nama_peralatan"/>
            <input type="text" id="jml_peralatan-<?=$no;?>"  name="jml_peralatan-<?=$no;?>"  value="<?=$peralatan['jumlah'];?>" class="jumlah_peralatan"/>
            <input type="button" class="hapus_kelompok" name="hapus_kelompok" value="Hapus"/>
        </span></li>
        <?php
            $sum+=$peralatan['jumlah'];
        }
        ?>
        <li  class="button">
	      <input type="button" name="tambah_peralatan" id="tambah_peralatan" value="Tambah Baris"/>
	    </li>
    </ul>
    <ul>
		<li class="header"><span>Material</span></li>
		<li class="desc">
			<span class="col1">Nama Material</span>
			<span class="col2">Jumlah</span>
			<span class="col3">Satuan</span>
		</li>
		<?php
        $no  = 0;
        $sum = 0;
        foreach($data['material'] as $material){
        ?>
        <li><span>
            <label><?=++$no;?></label>
            <input type="text" id="nama_material-<?=$no;?>"    name="nama_material-<?=$no;?>"    value="<?=$material['nama'];?>" class="nama_material"/>
            <input type="text" id="jml_material-<?=$no;?>"     name="jml_material-<?=$no;?>"     value="<?=$material['jumlah'];?>" class="jumlah_material"/>
            <input type="text" id="satuan_material-<?=$no;?>"  name="satuan_material-<?=$no;?>"  value="<?=$material['satuan'];?>" class="satuan_material"/>
            <input type="button" class="hapus_kelompok" name="hapus_kelompok" value="Hapus"/>
        </span></li>
        <?php
            $sum+=$material['jumlah'];
        }
        ?>
        <li class="button">
	      <input type="button" name="tambah_material" id="tambah_material" value="Tambah Baris"/>
	    </li>
	</ul>
	<ul>
		<li class="header"><span>Kondisi</span></li>
		<li><span>
            <label>Kondisi Awal:</label>
            <select name="kondisi_awal" id="kondisi_awal">
				<option value="sangat_baik" <?=$data['kondisi_awal']=='sangat_baik'?'selected="selected"':'';?> >Sangat Baik</option>
				<option value="baik"        <?=$data['kondisi_awal']=='baik'       ?'selected="selected"':'';?> >Baik</option>
				<option value="buruk"       <?=$data['kondisi_awal']=='buruk'      ?'selected="selected"':'';?> >Buruk</option>
			</select>
        </span></li>
		<li><span>
            <label>Catatan:</label>
            <textarea id="catatan" name="catatan"  cols="65" rows="4" ><?=$data['catatan'];?></textarea>
        </span></li>
    </ul>
	<ul>
		<li class="header"><span>Simpan</span></li>
		<li class="button"><span>
			<input type="submit" name="submit" id="submit" value="Simpan Data" class="simpan"/>
		</span></li>
	</ul>
</form>